 @layout("/common/_container.html"){
 <style>
     .hr-line-dashed{display:none}
     .has-feedback .form-control{
         padding-right: 0;
     }
 </style>
 <div class="animated fadeInRight ">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <form id="audienceImportForm" class="wizard-big" enctype="multipart/form-data" method="post">
                            <h1>上传数据文件</h1>
                            <fieldset>
                                <div class="row">
                                    <div class="col-sm-8">
                                        <div class="form-group">
	                                        <ul>
	                                           <li class="mb10">批量上传文件前请先确认文件格式是否符合要求，可点击"<a href="/static/admup/audienceImport.xls" class="lan">下载模板</a>"，查看文件格式。</li>
								        	   <li class="mb10">批量上传文件支持格式：xlsx、xls，其它格式均不支持。</li>
	                                    	</ul>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-xs-12 init">文件上传 *</label>
                                            <div class="col-xs-12 init">
                                                <#file id="fileName" name="附件名称" underline="true" />
                                        	</div>
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="text-center">
                                            <div style="margin-top: 20px">
                                                <i class="fa fa-sign-in" style="font-size: 180px;color: #e5e5e5 "></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
                            </fieldset>
                            
                            <!-- 导入数据开关 -->
                            <input type="hidden" id="pushDataBase" value="">
                             <!-- 进入第三步开关,效验失败不能进入第三步 -->
                            <input type="hidden" id="goStep3" value="">
                            
                            <h1>数据有效性校验</h1>
                            <fieldset>
                                <h2 class="mb10">信息提示</h2>
                                <div class="row" >
                                    <div class="col-sm-6" id="success">
                                        <div class="form-group">
                                            <label>校验成功</label>
                                        </div>
                                    </div>
                                    <div class="col-sm-6" style="display:none" id="faile">
                                        <div class="form-group">
                                            <label>校验失败</label>
                                        </div>
                                         <div class="form-group">
                                            <label class="mb20">错误提示</label>
                                            <div id="err"></div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                            <h1>数据导入系统</h1>
                            <fieldset>
                                <div class="text-center" style="margin-top: 120px" id="success_push">
                                    <h2>恭喜您!数据导入成功  </h2>
                                </div>
                                 <div class="text-center" style="margin-top: 120px;display:none" id="faile_push" >
                                    <h2>很遗憾!数据导入失败  </h2>
                                </div>
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>
        </div>
      </div>
 	  <#loading />
 <script>
 $(function ()
         {
             $("#audienceImportForm").steps({
                 headerTag: "h1",
                 bodyTag: "fieldset",
                 onStepChanging : function(event,currentIndex, newIndex){
                	 //console.log('执行onStepChanging!');
                	 //console.log('currentIndex:'+currentIndex+",newIndex:"+newIndex);
                	 var goStep3 =  $("#goStep3").val();
                	 var fileName = $.trim($('#fileName').val());
               		 if(fileName.length==0 && newIndex==1 && currentIndex==0){
               			Feng.error("请先选择文件!");
               			return false;
               		 }
               		 if(goStep3=="false" && newIndex==2 && currentIndex==1){
               			Feng.error("效验失败!");
               			return false;
               		 }

                	 return true;
                 },
                 onStepChanged : function(event,currentIndex, priorIndex) {
                	 //console.log('执行onStepChanged!');
                	 //console.log('currentIndex:'+currentIndex+",priorIndex:"+priorIndex);
                	 var pushDataBase =  $("#pushDataBase").val();
                	 var goStep3 =  $("#goStep3").val();
                	 //验证
                	 if(priorIndex==0 && currentIndex==1){
	                	 AudienceImportDlg.upload();
                	 }
                	 //导入
                	 if(pushDataBase=="true" && priorIndex==1 && currentIndex==2 && goStep3=="true"){
	                	 AudienceImportDlg.pushData2Base();
                	 }
                	 //阻止数据重复导入
                	 if(priorIndex==2 && currentIndex==1){
                		 $("#pushDataBase").val("false");
                	 }
                	 //允许数据导入
                	 if(priorIndex==0 && currentIndex==1){
                		 $("#pushDataBase").val("true");
                	 }
                 },
                 onFinishing : function(event,currentIndex){
                	 //console.log('执行onFinishing!');
                	 //console.log('currentIndex:'+currentIndex);
                	 return true;
                 },
                 onFinished : function(event,currentIndex){
                	 //console.log('执行onFinished!');
                	 //console.log('currentIndex:'+currentIndex);
                	 window.location.reload();
                 }
             });
         });
    </script>
   <script src="${ctxPath}/static/modular/system/audience/audience_import.js"></script>
@}
 